// Copyright: Personal possession of Nguyen Minh Kha
// Decription: This class combine object, manage the world game
// Date time: 01:06PM, 07/08/2011(mm/dd/yyyy)
// License: free source
// Version: 1.0
// Writer: Nguyen Minh Kha

#ifndef GAMEFRAMEWORK_WORLD_H_
#define GAMEFRAMEWORK_WORLD_H_


#include "screen.h"
#include "control.h"
#include "audio.h"
#include "log.h"

#include "map.h"

class World
{
  //
  // Static for callback
  //

private:
  static void WINAPI RenderCallBack(LPVOID param);
  static void WINAPI ControlCallBack(LPVOID param);
  static void WINAPI ThreadControlCallBack(LPVOID param);
  static void WINAPI ThreadCollisionCallBack(LPVOID param);
  static void WINAPI ThreadEventCallBack(LPVOID param);
  //
  // Constructor
  //

public:
  World(void);
  virtual ~World(void);


  //
  // Method
  //
public:
  int Init(HINSTANCE hInstance, HWND hWnd);
  void Exeute();
  void End();

private:
  int WINAPI ExecuteRender();
  int WINAPI ExecuteControl();
  int WINAPI ExecuteControlThread();
  int WINAPI ExecuteCollisionThread();
  int WINAPI ExecuteEventThread();

private:
  // World variable
  bool worldIsDestroy;

  /* Frame work pointer */

  HINSTANCE hInstance;
  HWND hWnd;
  Screen screen;
  Control control;
  Audio audio;
  Log log;
  Map map;

  /* Thread handler */

  HANDLE handleRender;
  HANDLE handleControl;
  HANDLE handleControlThread;
  HANDLE handleCollisionThread;
  HANDLE handleEventThread;

  /* Manager: create and init static pointer */

  ObjectsManager objectsManager;
  RenderableManager renderManager;
  ControllableManager controlManager;
  CollisionableManager collisionManager;
  EventableManager eventManager;
  TexturesManager texturesManager;

};
#endif // GAMEFRAMEWORK_WORLD_H_
